package org.tigris.atlas.examples.persist;

import junit.framework.TestCase;

import org.tigris.atlas.examples.service.ExistingPkExampleServiceResponse;
import org.tigris.atlas.examples.service.delegate.EntityMaintenanceServiceDelegate;
import org.tigris.atlas.examples.service.delegate.ServiceDelegateFactory;
import org.tigris.atlas.examples.transfer.ExistingPkExample;
import org.tigris.atlas.examples.transfer.ExistingPkExamplePK;
import org.tigris.atlas.examples.transfer.TransferObjectFactory;

public class TestExistingPrimaryKey extends TestCase {
	
	ExistingPkExample example;
	EntityMaintenanceServiceDelegate delegate;
	private static String existingPkValue;
	
	protected void setUp() throws Exception {
		super.setUp();

		example = TransferObjectFactory.createExistingPkExample();	
		existingPkValue = Integer.toString(new Object().hashCode());
		delegate = ServiceDelegateFactory.createEntityMaintenanceServiceDelegate();
	}
	
	protected void tearDown() throws Exception {
		example = null;
		existingPkValue = null;
		delegate = null;
	}
	
	public void testPlaceholder() {
		assertNotNull("foo");
	}
	
	//TODO: reinstate this test - it can only be done inside the BO and not from the service tier
	/* public void testCreationWithExistingKey() {
		ExistingPkExample to = TransferObjectFactory.createExistingPkExample();
		to.setId(existingPkValue);
		to.getExistingPkExamplePK();
				
		ExistingPkExampleServiceResponse response = delegate.save(to);
		
		assertEquals("No errors should have been returned!", 0, response.getMessages().getErrorMessageCount());
		example = response.getExistingPkExample();
		
		ExistingPkExamplePK pk = TransferObjectFactory.createExistingPkExamplePK();
		pk.setId(existingPkValue);
		ExistingPkExample reselected = delegate.findByPrimaryKey(pk).getExistingPkExample();
		
		assertNotNull("This instance should have been saved!", reselected);
		
	}*/
	
}
